package org.jarraiders.musiclibrary.shared.domain;

import java.io.Serializable;
import java.util.UUID;

import org.jarraiders.musiclibrary.domain.Track;

/**
 * @author AlteroStudio
 */
public class TrackDTO implements Serializable {

	private static final long serialVersionUID = -4630915210596737614L;
	
	private String trackId;
	private String trackName;
	private int trackNumber;
	private String referencedAlbumId;

	public TrackDTO() {
	}
	
	private TrackDTO(String trackName, int trackNumber, String referencedAlbumId) {
		this.trackId = null;
		this.trackName = trackName;
		this.trackNumber = trackNumber;
		this.referencedAlbumId = referencedAlbumId;
	}

	/*public TrackDTO(Track track) {
		this.trackId = track.getTrackId().toString();
		this.trackName = track.getTrackTitle();
		this.trackNumber = track.getTrackNumber();
		this.referencedAlbumId = track.getReferencedAlbum().getAlbumId().toString();
	}*/
	
	public static TrackDTO getNewTrackDTO(String trackName, int trackNumber, String referencedAlbumId) {
		return new TrackDTO(trackName, trackNumber, referencedAlbumId);
	}

	public String getTrackId() {
		return trackId;
	}
	public void setTrackId(String uuid){
		this.trackId=uuid;
	}
	public String getTrackTitle() {
		return trackName;
	}

	public void setTrackTitle(String trackTitle) {
		this.trackName = trackTitle;
	}

	public int getTrackNumber() {
		return trackNumber;
	}

	public void setTrackNumber(int trackNumber) {
		this.trackNumber = trackNumber;
	}

	public String getReferencedAlbumId() {
		return referencedAlbumId;
	}

	public void setReferencedAlbumId(String referencedAlbumId) {
		this.referencedAlbumId = referencedAlbumId;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("TrackDTO [trackId=");
		builder.append(trackId);
		builder.append(", trackName=");
		builder.append(trackName);
		builder.append(", trackNumber=");
		builder.append(trackNumber);
		builder.append(", referencedAlbumId=");
		builder.append(referencedAlbumId);
		builder.append("]");
		return builder.toString();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime
				* result
				+ ((referencedAlbumId == null) ? 0 : referencedAlbumId
						.hashCode());
		result = prime * result + ((trackId == null) ? 0 : trackId.hashCode());
		result = prime * result
				+ ((trackName == null) ? 0 : trackName.hashCode());
		result = prime * result + trackNumber;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		TrackDTO other = (TrackDTO) obj;
		if (referencedAlbumId == null) {
			if (other.referencedAlbumId != null)
				return false;
		} else if (!referencedAlbumId.equals(other.referencedAlbumId))
			return false;
		if (trackId == null) {
			if (other.trackId != null)
				return false;
		} else if (!trackId.equals(other.trackId))
			return false;
		if (trackName == null) {
			if (other.trackName != null)
				return false;
		} else if (!trackName.equals(other.trackName))
			return false;
		if (trackNumber != other.trackNumber)
			return false;
		return true;
	}
}
